//
//  ViewController.m
//  testTransition3
//
//  Created by zsj1992 on 17/1/4.
//  Copyright © 2017年 bjhj. All rights reserved.
//

#import "ViewController.h"
#import "SecondViewController.h"

#import "customPresent.h"
#import "customDismiss.h"
#import "customInteraction.h"


@interface ViewController ()<UIViewControllerTransitioningDelegate>
@property (nonatomic,strong)customInteraction * customInterAction;


@end

@implementation ViewController


//点击了按钮-展示视图
- (IBAction)btnClick:(id)sender {
    
    SecondViewController * secondVC = [[SecondViewController alloc]init];
    
    secondVC.transitioningDelegate = self;
    
    [self presentViewController:secondVC animated:YES completion:nil];
    
    self.customInterAction.presentationVc = secondVC;

    
}


//如何显示secondVc
-(id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source{

    customPresent * present = [customPresent new];

    return present;

}


//如何隐藏secondVc
-(id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed{

    customDismiss * dismiss = [customDismiss new];

    return dismiss;

}







-(id<UIViewControllerInteractiveTransitioning>)interactionControllerForDismissal:(id<UIViewControllerAnimatedTransitioning>)animator {
   
    return self.customInterAction.interaction ? self.customInterAction : nil;

}


- (void)viewDidLoad {
    [super viewDidLoad];

    self.customInterAction = [[customInteraction alloc]init];;

}




@end
